Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use dotnet 8 feed. #1153

Merged
merged 4 commits into from
Sep 6, 2023
Merged

Use dotnet 8 feed. #1153

merged 4 commits into from
Sep 6, 2023

Conversation

nojaf
Copy link
Contributor

@nojaf nojaf commented Aug 24, 2023

WHAT

🤖 Generated by Copilot at ed906db

The pull request updates the FsAutoComplete project to use the latest F# compiler version and its new syntax tree representation. It modifies several modules and files that deal with code generation, syntax analysis, error detection, and completion suggestions. It also updates the paket.dependencies file to use the dotnet8 feed and the latest preview of FSharp.Compiler.Service.

🤖 Generated by Copilot at ed906db

We're sailing on the dotnet sea, with FSharp.Compiler.Service
We've got to keep our code in sync, with every breaking change
So heave away, me hearties, heave away with me
We'll update all the syntax trees, for FsAutoComplete

✨💥🔧

WHY

HOW

🤖 Generated by Copilot at ed906db

  • Updated the paket.dependencies file to use the dotnet8 feed and the latest preview version of the FSharp.Compiler.Service package (link, link)
  • Adapted to the breaking changes in the syntax tree representation by using the new syntax for the SynBinding, SynRationalConst, SynTyparDecl, SynType, SynConst, SynMeasure and SynExpr types in various functions and modules (link, link, link, link, link, link, link, link, link, link, link, link, link, link)
  • Handled the new CompletionItemKind.SuggestedName case in the TryGetCompletions method in the ParseAndCheckResults.fs file to support the new completion suggestions feature in the F# compiler (link)

WIP: not sure what CI will say. Compiled on my machine.

@baronfel
Copy link
Contributor

Thank you for starting this effort! It looks like things are pretty clean, actually, aside from the RemovePattern codefix. Happy to take a look at that if you'd like.

@nojaf
Copy link
Contributor Author

nojaf commented Aug 24, 2023

I'll check out the failing tests later this week. Might poke you when I'm stuck somewhere.

@nojaf
Copy link
Contributor Author

nojaf commented Aug 25, 2023

I think I may have found a potential regression with Pattern discard not allowed for union case that takes no data

match None with
| None x y -> ()

https://github.com/fsharp/FsAutoComplete/blob/452411b75d626b78698f7cd1aef6591da9d08bda/test/FsAutoComplete.Tests.Lsp/CodeFixTests/Tests.fs#L3239-L3251

It no longer works and I can no longer get the diagnostics when compiling with my local compiler.
(Using fsc File.fs --langversion:preview)

I've asked @edgarfgp if he could do some digging at the compiler side.

@edgarfgp
Copy link
Contributor

Found the problem and I will fix in the compiler next week :)

@baronfel
Copy link
Contributor

Great work, folks! Happy that FSAC can help detect bugs before they release:)

@baronfel
Copy link
Contributor

@jwosty here's where we're talking about the regression in the nightly builds of FSAC - its to do with the 725 diagnostic in pattern matching.

@nojaf
Copy link
Contributor Author

nojaf commented Aug 30, 2023

@edgarfgp I've updated FCS to a version that contains your latest fix. The unit tests now work as expected again!

There still of course might be other things before we can take this one in.

@@ -11,7 +11,7 @@ let title = "Add missing '=' to type definition"

/// a codefix that adds in missing '=' characters in type declarations
let fix (getFileLines: GetFileLines) =
Run.ifDiagnosticByCode (Set.ofList [ "3360" ]) (fun diagnostic codeActionParams ->
Run.ifDiagnosticByCode (Set.ofList [ "10" ]) (fun diagnostic codeActionParams ->
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nojaf
Copy link
Contributor Author

nojaf commented Aug 30, 2023

Side note: this test is unreliable on my machine:

testCaseAsync "can change namespace in open"
      <| CodeFix.check
        server
        """
        open System.Text.$0RegularEcpressions
        """
        validateDiags
        (selectCodeFix "RegularExpressions")
        """
        open System.Text.RegularExpressions
        """

The diagnostic message has a newline in there and sometimes the test fails because the message only contains the first part before the \r\n.

I checked the test over at FCS side:

    [<Fact>]
    let ``Suggest namespace correction`` () =
        FSharp """
open System.Text.RegularEcpressions
"""
        |> typecheck
        |> shouldFail
        |> withSingleDiagnostic (Error 39, Line 2, Col 18, Line 2, Col 36,
                                 ("The namespace 'RegularEcpressions' is not defined. Maybe you want one of the following:" + Environment.NewLine + "   RegularExpressions"))

This worked as expected.

EDIT: CI appears to have the same problem:

Error: Diagnostic with code 39 should suggest name. There isn't any element which satisfies given assertion <fun:validateDiags@2685-3>.
   at FsAutoComplete.Tests.CodeFixTests.Tests.validateDiags@2681-2.Invoke(Diagnostic[] diags) in D:\a\FsAutoComplete\FsAutoComplete\test\FsAutoComplete.Tests.Lsp\CodeFixTests\Tests.fs:line 2683
   at [email protected](Unit unitVar) in D:\a\FsAutoComplete\FsAutoComplete\test\FsAutoComplete.Tests.Lsp\Utils\CursorbasedTests.fs:line 43
   at Microsoft.FSharp.Control.AsyncPrimitives.CallThenInvoke[T,TResult](AsyncActivation`1 ctxt, TResult result1, FSharpFunc`2 part2) in D:\a\_work\1\s\src\FSharp.Core\async.fs:line 510
   at Microsoft.FSharp.Control.Trampoline.Execute(FSharpFunc`2 firstAction) in D:\a\_work\1\s\src\FSharp.Core\async.fs:line 148

  Failed FSAC.lsp.Ionide WorkspaceLoader.AdaptiveLspServer.NamedText.CodeFix-tests.ReplaceWithSuggestion.can change namespace in open [90 ms]
  Error Message:
   
Diagnostic with code 39 should suggest name. There isn't any element which satisfies given assertion <fun:validateDiags@2685-3>.
   at FsAutoComplete.Tests.CodeFixTests.Tests.validateDiags@2681-2.Invoke(Diagnostic[] diags) in D:\a\FsAutoComplete\FsAutoComplete\test\FsAutoComplete.Tests.Lsp\CodeFixTests\Tests.fs:line 2683
   at [email protected](Unit unitVar) in D:\a\FsAutoComplete\FsAutoComplete\test\FsAutoComplete.Tests.Lsp\Utils\CursorbasedTests.fs:line 43
   at Microsoft.FSharp.Control.AsyncPrimitives.CallThenInvoke[T,TResult](AsyncActivation`1 ctxt, TResult result1, FSharpFunc`2 part2) in D:\a\_work\1\s\src\FSharp.Core\async.fs:line 510
   at Microsoft.FSharp.Control.Trampoline.Execute(FSharpFunc`2 firstAction) in D:\a\_work\1\s\src\FSharp.Core\async.fs:line 148

@nojaf nojaf marked this pull request as ready for review August 30, 2023 13:20
@baronfel baronfel merged commit 1f1011a into ionide:nightly Sep 6, 2023
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants